Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Purge 6 MB of bloat from registry.json #2179

Merged
merged 1 commit into from
Nov 10, 2017

Conversation

HebaruSan
Copy link
Member

The registry.json file must be loaded and parsed before CKAN can do anything (CLI, GUI, etc.). Currently this file is about 21 MB and takes about 2 seconds to load on an SSD. Nearly 6 MB of it just sets assorted properties to null. But guess what value the deserializer uses if the property is absent? Yep: null. So those properties don't need to be there.

This pull request marks all the JsonProperty attributes that have at least one null value in registry.json with NullValueHandling = NullValueHandling.Ignore, which means that if the value is null, it will not be printed to the file. When the properties are not null, they will be saved and loaded normally. The file will load the same and CKAN will work the same either way.

$ ls -gG

-rw-r--r-- 1 21217174 Nov  9 16:58 before.json
-rw-r--r-- 1 15360478 Nov  9 17:22 debloat.json

Total change: 5856696 bytes, or 5.86 MB, or 27.6% of the current file size. This may yield a noticeable performance improvement on systems where registry.json is stored on a slower disk. (I don't think it's a straight 25% speed-up because the deserializer still needs to create the same objects and so on.)

There are still "ksp_version":null properties in my registry for a few mods with no version requirements. I think this is due to some custom deserialization code adjusting things independently of the attributes. It seems harmless for now.

Inspired by code review of #1888.

@HebaruSan HebaruSan added the Registry Issues affecting the registry label Nov 9, 2017
@politas politas merged commit 5d1cd0b into KSP-CKAN:master Nov 10, 2017
politas added a commit that referenced this pull request Nov 10, 2017
@HebaruSan HebaruSan deleted the fix/registry-bloat branch November 10, 2017 04:24
politas added a commit to politas/CKAN that referenced this pull request Nov 10, 2017
politas added a commit to politas/CKAN that referenced this pull request Nov 15, 2017
politas added a commit to politas/CKAN that referenced this pull request Nov 29, 2017
politas added a commit to politas/CKAN that referenced this pull request Dec 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Registry Issues affecting the registry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants